<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>MVVM</title>
</head>
<body>
  <div id="mvvm-app">
    <input type="text" v-model="someStr">
    <p>{{ getHelloWord }}</p>
    <p v-html="htmlStr"></p>
    <button v-on:click="clickBtn">change model</button>
    <p>注: 属性在包含对象，对象里在与上级的名字重叠的时候，会出现问题，（待解决）</p>
  </div>

  <script src="./js/observer.js"></script>
  <script src="./js/watcher.js"></script>
  <script src="./js/compile.js"></script>
  <script src="./js/mvvm.js"></script>
  <script>
    var vm = new MVVM({
      el: '#mvvm-app',
      data: {
        someStr: 'hello ',
        className: 'btn',
        htmlStr: '<span style="color: #f00;">red</span>'
      },
      computed: {
        getHelloWord: function() {
            return this.someStr;
        }
      },
      methods: {
        clickBtn: function(e) {
          var randomStrArr = ['childOne', 'childTwo', 'childThree'];
          // this.child.someStr = randomStrArr[parseInt(Math.random() * 3)];
        }
      }
    });
    /* vm.$watch('child.someStr', function() {
      console.log(arguments);
    }); */
  </script>
</body>
</html>